package Data;

public class Log {
	private static Log instance = new Log();
	public static Log getInstance() {
		return instance;
	}
	protected Log() {
		classShapes = new ClassWithShape[SIZE_OF_LOG];
		size = 0;
		index = -1;
	}
	
	
	private ClassWithShape[] classShapes;
	private int size, index;
	private final int SIZE_OF_LOG = 30;
	
	public void push(ClassWithShape cs) {
		if (index == SIZE_OF_LOG - 1) {
			for (int i = 0; i < SIZE_OF_LOG - 1; i++) {
				classShapes[i] = classShapes[i + 1];
			}
			index--;
		}
		index++;
		classShapes[index] = cs;
		size = index + 1;
	}
	
	public ClassWithShape getPrevious() {
		if (!canGetPrevious()) return null;
		else
			return classShapes[index-- - 1];
	}
	
	public ClassWithShape getNext() {
		if (!canGetNext()) return null;
		else
			return classShapes[++index];
	}
	
	public boolean canGetPrevious() {
		return (index < 1 ? false : true);
	}
	
	public boolean canGetNext() {
		return (index >= size - 1 ? false : true);
	}
	
	public void reset() {
		classShapes = new ClassWithShape[SIZE_OF_LOG];
		size = 0;
		index = -1;
	}
}
